package cn.threewaters.qtyy.web.controller.business;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.baomidou.mybatisplus.plugins.Page;

import cn.threewaters.qtyy.common.bean.PageBean;
import cn.threewaters.qtyy.common.bean.ResponseJson;
import cn.threewaters.qtyy.dic.one.queryparam.QuerySjzsLB;
import cn.threewaters.qtyy.dic.one.queryresult.ResultSjzs;
import cn.threewaters.qtyy.dic.one.queryresult.ResultSjzsLB;
import cn.threewaters.qtyy.service.business.SjzsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import springfox.documentation.annotations.ApiIgnore;

@Api(tags = "数据展示")
@Controller
@RequestMapping(value = "/sjzs")
public class SjzsController {

	@Autowired
	private SjzsService sjzsService;

	@ApiIgnore
	@ApiOperation(value = "数据展示页面")
	@RequestMapping(value = "/main", method = RequestMethod.GET)
	public ModelAndView main(ModelMap modelMap, String lkbh) {
		List<ResultSjzs> querySjzs = sjzsService.querySjzs(lkbh);
		modelMap.put("sjzss", querySjzs);
		modelMap.put("cou", querySjzs.size());
		return new ModelAndView("business/sjzs/sjzs", modelMap);
	}

	@ApiOperation(value = "列表")
	@RequestMapping(value = "/list", method = RequestMethod.GET)
	@ResponseBody
	public ResponseJson getList(PageBean page, QuerySjzsLB querySjzsLB) throws Exception {
		Page<ResultSjzsLB> pageResult = new Page<ResultSjzsLB>();
		List<ResultSjzsLB> querySjzs = sjzsService.querySjzs(querySjzsLB);
		pageResult.setRecords(querySjzs);
		pageResult.setTotal(querySjzs.size());
		return ResponseJson.builder().success(true).obj(pageResult).build();
	}

}
